 //
//  QICategoryViewController.swift
//  SameCity
//
//  Created by 秦江涛 on 2023/8/10.
//

import UIKit

class QICategoryViewController: QIBaseViewController {
    
    lazy var titleArr = [String]()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    

    lazy var lineView: JXCategoryIndicatorLineView = {
        let lineView = JXCategoryIndicatorLineView()
        lineView.lineStyle = .lengthen
        lineView.indicatorColor = Color333333
        return lineView
    }()
    
    lazy var myCategoryView: JXCategoryTitleView = {
       
        
        let myCategoryView = JXCategoryTitleView()
        myCategoryView.delegate = self
        myCategoryView.titleColor = Color999999
        myCategoryView.titleSelectedColor = Color333333
        myCategoryView.titleFont = SYSFONT(ofSize: 13)
        myCategoryView.titleSelectedFont = SYSFONT(ofSize: 14)
        myCategoryView.titles = titleArr
        myCategoryView.contentScrollView = listContainerView.scrollView
        myCategoryView.indicators = [lineView]
        myCategoryView.defaultSelectedIndex = 0
        return myCategoryView
    }()
    lazy var listContainerView: JXCategoryListContainerView = {
        let listContainerView = JXCategoryListContainerView(type: JXCategoryListContainerType.scrollView, delegate: self)
        listContainerView?.setDefaultSelectedIndex(0)
        return listContainerView!
    }()

}


extension QICategoryViewController: JXCategoryListContainerViewDelegate, JXCategoryViewDelegate {
    func number(ofListsInlistContainerView listContainerView: JXCategoryListContainerView!) -> Int {
        titleArr.count
    }
    
    func listContainerView(_ listContainerView: JXCategoryListContainerView!, initListFor index: Int) -> JXCategoryListContentViewDelegate! {
        return QICategoryView()
    }
    
    func categoryView(_ categoryView: JXCategoryBaseView!, didClickSelectedItemAt index: Int) {
        listContainerView.didClickSelectedItem(at: index)
    }
    
    func categoryView(_ categoryView: JXCategoryBaseView!, didScrollSelectedItemAt index: Int) {
        listContainerView.didClickSelectedItem(at: index)
    }
}
